package com.yang.contorller;


import com.yang.pojo.FoodType;
import com.yang.service.FoodTypeService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * Created by 杨天可 on 2022/3/29 14:16
 */
@RestController
@RequestMapping("/api/foodType")
public class FoodTypeController {
    @Resource
    FoodTypeService foodTypeService;

    /* 修改菜品类型*/
    @PostMapping("/save")
    public Map<String, Object> save(@RequestBody FoodType foodType){
        return foodTypeService.save(foodType);
    }

    /* 根据id查找菜品类型*/
    @GetMapping("/findById")
    public FoodType findById(@RequestParam("foodTypeId")Integer foodTypeId){
        return foodTypeService.findById(foodTypeId); }

    /* 删除菜品类型*/
    @GetMapping("/delFood")
    public Map<String, Object> delFood(@RequestParam("foodTypeId")Integer foodTypeId){ return foodTypeService.delFood(foodTypeId); }

    /* 查找所有菜品分类  <根据商家id进行了分类>*/
    @GetMapping("/findAll")
    public Map<String,Object> findAll(@RequestParam ("userId") Integer userId,
                                      @RequestParam ("currentPage") Integer currentPage,
                                      @RequestParam ("pageSize") Integer pageSize)
    {return foodTypeService.findAll(userId,currentPage,pageSize); }

    /*  根据商家查找菜品分类*/
    @GetMapping("/findAllList")
    public List<FoodType> findAllList()
    {return foodTypeService.findAllList(); }

    /* 根据当前菜品分类查找所属商家的所有菜品分类*/
    @GetMapping("/findFoodTypeByCurrentUser")
    public List<FoodType> findFoodTypeByCurrentUser(@RequestParam("userId") Integer userId){
        return foodTypeService.findFoodTypeByCurrentUser(userId);
    }
}
